package com.example.ixform.dao;

import com.example.ixform.dto.IdolProduction;
import com.example.ixform.dto.NetizenComment;
import com.example.ixform.entities.Netizen;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface NetizenRepository extends CrudRepository<Netizen,Long> {
    @Override
    List<Netizen> findAll();

    @Query(nativeQuery = true,value = "SELECT n.name, n.email as email, COUNT(cn.netizen_id) as commentCount " +
            "FROM netizen n left join comment_netizen cn ON cn.netizen_id = n.netizen_id " +
            "GROUP BY n.name, n.email ORDER BY 3 DESC;")
//    List<NetizenComment> netizenComments();

    Netizen findByNetizenId(long theId);


}
